<template>
  <el-container>
    <el-header style="background-color: #336688;line-height: 60px;">
      <h1 style="font-size: 30px;margin-top: 0;margin-left: 260px;color: white">租车后台管理系统
        <span style="float: right;font-size: 20px">欢迎{{user.username}}回来！
        <a href="javascript:void(0)" @click="logout()" style="color: orange;text-decoration: none">退出登录</a>
      </span></h1>
    </el-header>

    <el-container>
      <el-aside width="200px" style="margin-top: 20px">
        <el-menu active-text-color="orange" router>
          <a href="/">
            <img src="" width="150px" style="position: relative;top: 10px;left: 25px"></a>
          <el-divider></el-divider>
          <el-menu-item index="/admin/audit">
            <i class="el-icon-user-solid">用户审核</i>
          </el-menu-item>
          <el-menu-item index="/admin/index">
            <i class="el-icon-user">用户列表</i>
          </el-menu-item>
          <el-menu-item index="/admin/car">
            <i class="el-icon-picture">车辆管理</i>
          </el-menu-item>
          <el-menu-item index="/admin/city">
            <i class="el-icon-location-outline">城市管理</i>
          </el-menu-item>
          <el-menu-item index="/admin/brand">
            <i class="el-icon-collection-tag">品牌管理</i>
          </el-menu-item>
          <el-menu-item index="/admin/order">
            <i class="el-icon-info">订单管理</i>
          </el-menu-item>
<!--          <el-menu-item index="/admin/comment">
            <i class="el-icon-s-comment">评论管理</i>
          </el-menu-item>-->
        </el-menu>
      </el-aside>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: "AdminView",
  data() {
    return {
      user: localStorage.user? JSON.parse(localStorage.user).user:null,
    }
  },
  methods: {
    logout() {
      if (confirm("您确认退出登录吗?")) {
        this.axios.post("http://localhost:29081/users/logout")
            .then((response)=>{
              if (response.data.state == 20000){
                this.$message.success("退出登录");
                localStorage.clear();
                location.href = '/';    //返回首页
              }
            });
      }
    },
  },
}
</script>

<style scoped>

</style>